using UnityEngine;

namespace Crosstales.Common.Util
{
    // [Assembly-CSharp-firstpass.dll].Crosstales.Common.Util.Singleton<T>
    public abstract class Singleton<T> : MonoBehaviour
    {
        // Fields
        private bool dontDestroy;
        public static string PrefabPath;
        public static string GameObjectName;
        protected static T instance;
        private static readonly object lockObj;
        
        // Properties
        public static T Instance { get; set; }
        public bool DontDestroy { get; set; }
        
        // Methods
        public static T get_Instance()
        {
            var val_5;
            object val_6;
            var val_7;
            var val_8;
            var val_9;
            var val_10;
            val_5 = 536892587;
            if(mem[536892811] == 0)
            {
                    val_5 = 536892587;
            }
            
            if((mem[536892771] == 0) || (Crosstales.Common.Util.BaseHelper.isEditorMode == false))
            {
                goto label_6;
            }
            
            val_6 = 27342664;
            val_7 = 536882899;
            if(mem[536883123] == 0)
            {
                    val_7 = 536882899;
            }
            
            if((mem[536883083] + 72) == 0)
            {
                goto label_19;
            }
            
            val_6 = System.String.Format(format:  -1610601065, arg0:  System.Type.GetTypeFromHandle(handle:  new System.RuntimeTypeHandle() {value = __RuntimeMethodHiddenParam + 32 + 192}));
            UnityEngine.Debug.Log(message:  val_6);
            goto label_19;
            label_6:
            val_6 = mem[__RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 16];
            val_6 = __RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 16;
            if(val_6 == 0)
            {
                    val_8 = mem[__RuntimeMethodHiddenParam + 32];
                val_8 = __RuntimeMethodHiddenParam + 32;
                val_9 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_9 = __RuntimeMethodHiddenParam + 32 + 306;
                if((val_9 & 1) == 0)
            {
                    val_10 = val_8;
                val_8 = mem[__RuntimeMethodHiddenParam + 32];
                val_8 = __RuntimeMethodHiddenParam + 32;
                val_9 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_9 = __RuntimeMethodHiddenParam + 32 + 306;
            }
            else
            {
                    val_10 = val_8;
            }
            
                if((val_9 & 1) == 0)
            {
                    val_8 = val_8;
            }
            
            }
            
            label_19:
            if(((__RuntimeMethodHiddenParam + 32 + 192 + 8 + 306) & 1) != 0)
            {
                    return (Unknown)__RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 16;
            }
            
            return (Unknown)__RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 16;
        }
        protected static void set_Instance(T value)
        {
            var val_2;
            var val_3;
            val_2 = mem[__RuntimeMethodHiddenParam + 32];
            val_2 = __RuntimeMethodHiddenParam + 32;
            if(((__RuntimeMethodHiddenParam + 32 + 306) & 1) == 0)
            {
                    val_2 = val_2;
            }
            
            System.Threading.Monitor.Enter(obj:  __RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 24, lockTaken:  true);
            mem2[0] = value;
            var val_1 = (__RuntimeMethodHiddenParam + 32 + 192 + 8 + 184) + 16;
            label_16:
            if(0 != 0)
            {
                    System.Threading.Monitor.Exit(obj:  __RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 24);
            }
            
            if(0 == 0)
            {
                    return;
            }
            
            val_3 = 0;
            if(0 != 1)
            {
                goto label_17;
            }
            
            goto label_16;
            label_17:
            if(0 != 0)
            {
                    System.Threading.Monitor.Exit(obj:  __RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 24);
            }
        
        }
        public bool get_DontDestroy()
        {
            return (bool)this;
        }
        public void set_DontDestroy(bool value)
        {
            mem[1152921504930430424] = value;
        }
        protected virtual void Awake()
        {
            object val_17;
            var val_18;
            var val_19;
            var val_20;
            var val_21;
            var val_22;
            var val_23;
            var val_24;
            val_17 = __RuntimeMethodHiddenParam;
            val_18 = 536882899;
            if(mem[536883123] == 0)
            {
                    val_18 = 536882899;
            }
            
            val_19 = 27356920;
            if((mem[536883083] + 72) != 0)
            {
                    float val_1 = UnityEngine.Time.realtimeSinceStartup;
                UnityEngine.Debug.Log(message:  System.String.Format(format:  -1610594707, arg0:  536892547, arg1:  System.Type.GetTypeFromHandle(handle:  new System.RuntimeTypeHandle() {value = __RuntimeMethodHiddenParam + 32 + 192})));
            }
            
            val_20 = 536882909;
            if(mem[536883133] == 0)
            {
                    val_20 = 536882909;
            }
            
            mem2[0] = UnityEngine.Application.isPlaying;
            if((__RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 16) == 0)
            {
                    val_21 = mem[__RuntimeMethodHiddenParam + 32 + 192 + 8];
                val_21 = __RuntimeMethodHiddenParam + 32 + 192 + 8;
                if(((__RuntimeMethodHiddenParam + 32 + 192 + 8 + 306) & 1) == 0)
            {
                    val_21 = val_21;
            }
            
                if(Crosstales.Common.Util.BaseHelper.isEditorMode == true)
            {
                    return;
            }
            
                if(mem[536883133] == 0)
            {
                    return;
            }
            
                UnityEngine.Object.DontDestroyOnLoad(target:  this.transform.root.gameObject);
                return;
            }
            
            if(Crosstales.Common.Util.BaseHelper.isEditorMode == true)
            {
                    return;
            }
            
            if(mem[536883133] == 0)
            {
                    return;
            }
            
            if((__RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 16) == this)
            {
                    return;
            }
            
            if((-1610604745) != 0)
            {
                    val_22 = -1610604745;
            }
            else
            {
                    val_22 = 0;
            }
            
            if(mem[536881491] == 0)
            {
                    throw new ArrayTypeMismatchException();
            }
            
            mem[536881499] = val_22;
            if(mem[536881491] <= 1)
            {
                    throw new ArrayTypeMismatchException();
            }
            
            mem[536881507] = System.Type.GetTypeFromHandle(handle:  new System.RuntimeTypeHandle() {value = __RuntimeMethodHiddenParam + 32 + 192});
            if((-1610612073) != 0)
            {
                    val_23 = -1610612073;
            }
            else
            {
                    val_23 = 0;
            }
            
            if(mem[536881491] <= 2)
            {
                    throw new ArrayTypeMismatchException();
            }
            
            mem[536881515] = val_23;
            if(mem[536881491] <= 3)
            {
                    throw new ArrayTypeMismatchException();
            }
            
            val_19 = 27519608;
            mem[536881523] = System.Environment.NewLine;
            if((-1610602405) != 0)
            {
                    val_24 = -1610602405;
            }
            else
            {
                    val_24 = 0;
            }
            
            if(mem[536881491] <= 4)
            {
                    throw new ArrayTypeMismatchException();
            }
            
            mem[536881531] = val_24;
            val_17 = +536881467;
            UnityEngine.Debug.LogWarning(message:  val_17, context:  this);
            UnityEngine.Object.Destroy(obj:  this.gameObject, t:  0.1f);
        }
        protected virtual void OnDestroy()
        {
            var val_6;
            var val_7;
            if((__RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 16) != this)
            {
                    return;
            }
            
            val_6 = 536882899;
            if(mem[536883123] == 0)
            {
                    val_6 = 536882899;
            }
            
            if((mem[536883083] + 72) != 0)
            {
                    float val_2 = UnityEngine.Time.realtimeSinceStartup;
                val_7 = mem[__RuntimeMethodHiddenParam + 32 + 192 + 8];
                val_7 = __RuntimeMethodHiddenParam + 32 + 192 + 8;
                if(((__RuntimeMethodHiddenParam + 32 + 192 + 8 + 306) & 1) == 0)
            {
                    val_7 = val_7;
            }
            
                int val_4 = __RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 16.GetInstanceID();
                UnityEngine.Debug.Log(message:  System.String.Format(format:  -1610594701, arg0:  536892547, arg1:  System.Type.GetTypeFromHandle(handle:  new System.RuntimeTypeHandle() {value = __RuntimeMethodHiddenParam + 32 + 192}), arg2:  536888099));
            }
            
            if(536884939 != 0)
            {
                    return;
            }
        
        }
        protected virtual void OnApplicationQuit()
        {
            var val_1;
            var val_2;
            var val_3;
            val_1 = 536892587;
            if(mem[536892811] == 0)
            {
                    val_1 = 536892587;
            }
            
            mem2[0] = 1;
            val_2 = 536882899;
            if(mem[536883123] == 0)
            {
                    val_2 = 536882899;
            }
            
            if((mem[536883083] + 72) != 0)
            {
                    UnityEngine.Debug.Log(message:  -1610604799, context:  this);
            }
            
            val_3 = 536882909;
            if(mem[536883133] == 0)
            {
                    val_3 = 536882909;
            }
            
            mem2[0] = 0;
        }
        public static void CreateInstance(bool searchExistingGameObject = True, bool deleteExistingInstance = False)
        {
            object val_21;
            var val_22;
            UnityEngine.Object val_23;
            var val_24;
            var val_25;
            var val_26;
            var val_27;
            var val_28;
            var val_29;
            var val_30;
            var val_31;
            var val_32;
            var val_33;
            var val_34;
            var val_35;
            var val_36;
            var val_37;
            var val_38;
            var val_39;
            var val_40;
            var val_41;
            var val_42;
            var val_43;
            var val_44;
            var val_45;
            var val_46;
            var val_47;
            var val_48;
            var val_49;
            var val_50;
            var val_51;
            var val_52;
            var val_53;
            var val_54;
            var val_55;
            var val_56;
            val_22 = 27342664;
            val_23 = searchExistingGameObject;
            val_24 = 536882899;
            if(mem[536883123] == 0)
            {
                    val_24 = 536882899;
            }
            
            if((mem[536883083] + 72) != 0)
            {
                    val_21 = System.String.Format(format:  -1610601063, arg0:  System.Type.GetTypeFromHandle(handle:  new System.RuntimeTypeHandle() {value = __RuntimeMethodHiddenParam + 32 + 192}));
                UnityEngine.Debug.Log(message:  val_21);
            }
            
            if(deleteExistingInstance != false)
            {
                    val_25 = mem[__RuntimeMethodHiddenParam + 32];
                val_25 = __RuntimeMethodHiddenParam + 32;
                val_26 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_26 = __RuntimeMethodHiddenParam + 32 + 306;
                if((val_26 & 1) == 0)
            {
                    val_27 = val_25;
                val_25 = mem[__RuntimeMethodHiddenParam + 32];
                val_25 = __RuntimeMethodHiddenParam + 32;
                val_26 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_26 = __RuntimeMethodHiddenParam + 32 + 306;
            }
            else
            {
                    val_27 = val_25;
            }
            
                if((val_26 & 1) == 0)
            {
                    val_25 = val_25;
            }
            
            }
            
            if((__RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 16) != 0)
            {
                    return;
            }
            
            if(val_23 == false)
            {
                goto label_20;
            }
            
            val_28 = mem[__RuntimeMethodHiddenParam + 32];
            val_28 = __RuntimeMethodHiddenParam + 32;
            if(((__RuntimeMethodHiddenParam + 32 + 306) & 1) == 0)
            {
                    val_28 = val_28;
            }
            
            val_29 = mem[__RuntimeMethodHiddenParam + 32];
            val_29 = __RuntimeMethodHiddenParam + 32;
            val_30 = mem[__RuntimeMethodHiddenParam + 32 + 306];
            val_30 = __RuntimeMethodHiddenParam + 32 + 306;
            if((val_30 & 1) == 0)
            {
                    val_31 = val_29;
                val_29 = mem[__RuntimeMethodHiddenParam + 32];
                val_29 = __RuntimeMethodHiddenParam + 32;
                val_30 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_30 = __RuntimeMethodHiddenParam + 32 + 306;
            }
            else
            {
                    val_31 = val_29;
            }
            
            if((val_30 & 1) == 0)
            {
                    val_29 = val_29;
            }
            
            val_32 = mem[__RuntimeMethodHiddenParam + 32 + 192 + 16];
            val_32 = __RuntimeMethodHiddenParam + 32 + 192 + 16;
            if(((__RuntimeMethodHiddenParam + 32 + 192 + 16 + 306) & 1) == 0)
            {
                    val_32 = val_32;
            }
            
            if((UnityEngine.Object.FindObjectOfType(type:  System.Type.GetTypeFromHandle(handle:  new System.RuntimeTypeHandle() {value = __RuntimeMethodHiddenParam + 32 + 192}))) == null)
            {
                goto label_31;
            }
            
            val_21 = X0;
            if(X0 == true)
            {
                goto label_32;
            }
            
            label_31:
            val_21 = 0;
            label_32:
            label_20:
            val_23 = mem[__RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 16];
            val_23 = __RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 16;
            if(val_23 != 0)
            {
                    return;
            }
            
            if((System.String.IsNullOrEmpty(value:  __RuntimeMethodHiddenParam + 32 + 192 + 8 + 184)) != true)
            {
                    val_33 = mem[__RuntimeMethodHiddenParam + 32];
                val_33 = __RuntimeMethodHiddenParam + 32;
                val_34 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_34 = __RuntimeMethodHiddenParam + 32 + 306;
                if((val_34 & 1) == 0)
            {
                    val_35 = val_33;
                val_33 = mem[__RuntimeMethodHiddenParam + 32];
                val_33 = __RuntimeMethodHiddenParam + 32;
                val_34 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_34 = __RuntimeMethodHiddenParam + 32 + 306;
            }
            else
            {
                    val_35 = val_33;
            }
            
                if((val_34 & 1) == 0)
            {
                    val_33 = val_33;
            }
            
                if((__RuntimeMethodHiddenParam + 32 + 192 + 8 + 184) == 0)
            {
                    UnityEngine.Debug.LogWarning(message:  -1610603755(-1610603755) + __RuntimeMethodHiddenParam + 32 + 192 + 8 + 184(__RuntimeMethodHiddenParam + 32 + 192 + 8 + 184));
            }
            else
            {
                    val_36 = 536882899;
                if(mem[536883123] == 0)
            {
                    val_36 = 536882899;
            }
            
                if((mem[536883083] + 72) != 0)
            {
                    float val_10 = UnityEngine.Time.realtimeSinceStartup;
                val_37 = mem[__RuntimeMethodHiddenParam + 32];
                val_37 = __RuntimeMethodHiddenParam + 32;
                if(((__RuntimeMethodHiddenParam + 32 + 306) & 1) == 0)
            {
                    val_37 = val_37;
            }
            
                val_21 = mem[__RuntimeMethodHiddenParam + 32 + 192];
                val_21 = __RuntimeMethodHiddenParam + 32 + 192;
                UnityEngine.Debug.Log(message:  System.String.Format(format:  -1610594703, arg0:  536892547, arg1:  System.Type.GetTypeFromHandle(handle:  new System.RuntimeTypeHandle() {value = val_21})));
            }
            
                val_38 = mem[__RuntimeMethodHiddenParam + 32];
                val_38 = __RuntimeMethodHiddenParam + 32;
                val_39 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_39 = __RuntimeMethodHiddenParam + 32 + 306;
                if((val_39 & 1) == 0)
            {
                    val_40 = val_38;
                val_38 = mem[__RuntimeMethodHiddenParam + 32];
                val_38 = __RuntimeMethodHiddenParam + 32;
                val_39 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_39 = __RuntimeMethodHiddenParam + 32 + 306;
            }
            else
            {
                    val_40 = val_38;
            }
            
                if((val_39 & 1) == 0)
            {
                    val_38 = val_38;
            }
            
                val_41 = mem[__RuntimeMethodHiddenParam + 32];
                val_41 = __RuntimeMethodHiddenParam + 32;
                if(((__RuntimeMethodHiddenParam + 32 + 306) & 1) == 0)
            {
                    val_41 = val_41;
            }
            
                val_42 = mem[__RuntimeMethodHiddenParam + 32];
                val_42 = __RuntimeMethodHiddenParam + 32;
                val_43 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_43 = __RuntimeMethodHiddenParam + 32 + 306;
                if((val_43 & 1) == 0)
            {
                    val_44 = val_42;
                val_42 = mem[__RuntimeMethodHiddenParam + 32];
                val_42 = __RuntimeMethodHiddenParam + 32;
                val_43 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_43 = __RuntimeMethodHiddenParam + 32 + 306;
            }
            else
            {
                    val_44 = val_42;
            }
            
                if((val_43 & 1) == 0)
            {
                    val_42 = val_42;
            }
            
                val_45 = mem[__RuntimeMethodHiddenParam + 32];
                val_45 = __RuntimeMethodHiddenParam + 32;
                val_46 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_46 = __RuntimeMethodHiddenParam + 32 + 306;
                if((val_46 & 1) == 0)
            {
                    val_47 = val_45;
                val_45 = mem[__RuntimeMethodHiddenParam + 32];
                val_45 = __RuntimeMethodHiddenParam + 32;
                val_46 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_46 = __RuntimeMethodHiddenParam + 32 + 306;
            }
            else
            {
                    val_47 = val_45;
            }
            
                if((val_46 & 1) == 0)
            {
                    val_45 = val_45;
            }
            
                val_48 = mem[__RuntimeMethodHiddenParam + 32];
                val_48 = __RuntimeMethodHiddenParam + 32;
                if(((__RuntimeMethodHiddenParam + 32 + 306) & 1) == 0)
            {
                    val_48 = val_48;
            }
            
                __RuntimeMethodHiddenParam + 32 + 192 + 72.name = __RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 8;
            }
            
            }
            
            val_23 = mem[__RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 16];
            val_23 = __RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 16;
            if(val_23 != 0)
            {
                    return;
            }
            
            val_21 = 27342680;
            if(Crosstales.Common.Util.BaseHelper.isEditorMode == true)
            {
                    return;
            }
            
            val_49 = 536882899;
            if(mem[536883123] == 0)
            {
                    val_49 = 536882899;
            }
            
            if((mem[536883083] + 72) != 0)
            {
                    float val_15 = UnityEngine.Time.realtimeSinceStartup;
                val_50 = mem[__RuntimeMethodHiddenParam + 32];
                val_50 = __RuntimeMethodHiddenParam + 32;
                if(((__RuntimeMethodHiddenParam + 32 + 306) & 1) == 0)
            {
                    val_50 = val_50;
            }
            
                val_22 = 27550400;
                bool val_18 = Crosstales.Common.Util.BaseHelper.isEditorMode;
                UnityEngine.Debug.Log(message:  System.String.Format(format:  -1610594705, arg0:  536892547, arg1:  System.Type.GetTypeFromHandle(handle:  new System.RuntimeTypeHandle() {value = __RuntimeMethodHiddenParam + 32 + 192}), arg2:  536883173));
            }
            
            UnityEngine.GameObject val_20 = 536886569;
            val_20 = new UnityEngine.GameObject(name:  __RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 8);
            val_51 = mem[__RuntimeMethodHiddenParam + 32];
            val_51 = __RuntimeMethodHiddenParam + 32;
            val_52 = mem[__RuntimeMethodHiddenParam + 32 + 306];
            val_52 = __RuntimeMethodHiddenParam + 32 + 306;
            if((val_52 & 1) == 0)
            {
                    val_53 = val_51;
                val_51 = mem[__RuntimeMethodHiddenParam + 32];
                val_51 = __RuntimeMethodHiddenParam + 32;
                val_52 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_52 = __RuntimeMethodHiddenParam + 32 + 306;
            }
            else
            {
                    val_53 = val_51;
            }
            
            if((val_52 & 1) == 0)
            {
                    val_51 = val_51;
            }
            
            val_54 = mem[__RuntimeMethodHiddenParam + 32];
            val_54 = __RuntimeMethodHiddenParam + 32;
            val_23 = val_20;
            val_55 = mem[__RuntimeMethodHiddenParam + 32 + 306];
            val_55 = __RuntimeMethodHiddenParam + 32 + 306;
            if((val_55 & 1) == 0)
            {
                    val_56 = val_54;
                val_54 = mem[__RuntimeMethodHiddenParam + 32];
                val_54 = __RuntimeMethodHiddenParam + 32;
                val_55 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_55 = __RuntimeMethodHiddenParam + 32 + 306;
            }
            else
            {
                    val_56 = val_54;
            }
            
            if((val_55 & 1) != 0)
            {
                    return;
            }
            
            val_54 = val_54;
        }
        public static void DeleteInstance()
        {
            var val_3;
            var val_4;
            var val_5;
            if((__RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 16) == 0)
            {
                    return;
            }
            
            val_3 = mem[__RuntimeMethodHiddenParam + 32];
            val_3 = __RuntimeMethodHiddenParam + 32;
            val_4 = mem[__RuntimeMethodHiddenParam + 32 + 306];
            val_4 = __RuntimeMethodHiddenParam + 32 + 306;
            if((val_4 & 1) == 0)
            {
                    val_5 = val_3;
                val_3 = mem[__RuntimeMethodHiddenParam + 32];
                val_3 = __RuntimeMethodHiddenParam + 32;
                val_4 = mem[__RuntimeMethodHiddenParam + 32 + 306];
                val_4 = __RuntimeMethodHiddenParam + 32 + 306;
            }
            else
            {
                    val_5 = val_3;
            }
            
            if((val_4 & 1) == 0)
            {
                    val_3 = val_3;
            }
            
            UnityEngine.Object.Destroy(obj:  __RuntimeMethodHiddenParam + 32 + 192 + 8 + 184 + 16.gameObject);
        }
        protected Singleton<T>()
        {
            mem[1152921504930430424] = 1;
        }
        private static Singleton<T>()
        {
            var val_5 = mem[__RuntimeMethodHiddenParam + 32];
            val_5 = __RuntimeMethodHiddenParam + 32;
            if(((__RuntimeMethodHiddenParam + 32 + 306) & 1) == 0)
            {
                    val_5 = val_5;
            }
            
            mem2[0] = System.Type.GetTypeFromHandle(handle:  new System.RuntimeTypeHandle() {value = __RuntimeMethodHiddenParam + 32 + 192});
            var val_2 = (__RuntimeMethodHiddenParam + 32 + 192 + 8 + 184) + 8;
            object val_3 = 536890179;
            val_3 = new System.Object();
            mem2[0] = val_3;
            var val_4 = (__RuntimeMethodHiddenParam + 32 + 192 + 8 + 184) + 24;
            throw new NullReferenceException();
        }
    
    }

}
